/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 */

import { expect, test } from '@jest/globals';
import { hvigorCore } from '@ohos/hvigor';

import { CommonConst } from '../../../src/const/common-const.js';
import { InjectUtil } from '../../../src/utils/inject-util.js';

test('test isHotReload fn', () => {
  // 默认返回false
  expect(InjectUtil.isHotReload()).toEqual(false);

  // 无效值返回false
  hvigorCore.getExtraConfig().set(CommonConst.HOT_RELOAD, 'abc');
  expect(InjectUtil.isHotReload()).toEqual(false);

  hvigorCore.getExtraConfig().set(CommonConst.HOT_RELOAD, '');
  expect(InjectUtil.isHotReload()).toEqual(false);

  hvigorCore.getExtraConfig().set(CommonConst.HOT_RELOAD, 'false');
  expect(InjectUtil.isHotReload()).toEqual(false);

  hvigorCore.getExtraConfig().set(CommonConst.HOT_RELOAD, 'true');
  expect(InjectUtil.isHotReload()).toEqual(true);
});
